import { UserEntity } from '@/user/entities/user.mysql.entity'
import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'

@Entity({ name: 'avatar' })
export class AvatarEntity {
  @PrimaryGeneratedColumn()
  id?: number
  @Column({ comment: "图像类型" })
  mimetype: string
  @Column({ comment: "文件名称" })
  filename: string
  @Column({ comment: "文件大小" })
  size: number
  @Column({ comment: "用户id 一对一关联" })
  userId: number

  /**
   * 关系连接
   * 删除用户时一起删除
   */
  @ManyToOne(() => UserEntity, { onDelete: 'CASCADE' })
  @JoinColumn()
  user: UserEntity
}